package com.service;
import com.alibaba.fastjson.JSON;
import com.dao.HatAreaDao;
import com.entity.HatArea;
import com.entity.HatCity;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;

@Service
public class HatAreaService
{
    @Resource
    private HatAreaDao hatAreaDao;

    //根据cityId返回指定地区的json格式字符串
    public String returnAreaComboBoxJsonStr( Integer cityId )
    {
        ArrayList<HatArea> careaList = hatAreaDao.getAreaByCityId( cityId );
        String jsonStr = JSON.toJSONString(careaList );
        System.out.println( jsonStr );

        return jsonStr;
    }

    //根据id查询市区
    public String returnAreaNameById( Integer id )
    {
        HatArea hatArea = hatAreaDao.getAreaById( id );

        return hatArea.getArea();
    }
}
